package control.module.po.authmanage;

import base.validation.annotation.Uniqueness;
import base.validation.groups.RoleSave;
import base.validation.groups.RoleUpdate;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import control.module.po.base.BasePo;
import control.service.IRoleService;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * <p>
 * 角色表
 * </p>
 *
 * @author cyj
 * @since 2020-10-20
 */
@TableName("t_role")
@Accessors(chain = true)
@Data
public class Role extends BasePo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    @NotNull(message = "修改角色id不为空", groups = RoleUpdate.class)
    private Integer id;

    /**
     * 角色名
     */
    @Length(message = "roleName长度为1-64", min = 1, max = 20, groups = {RoleSave.class, RoleUpdate.class})
    @Uniqueness(message = "roleName 已存在", classType = IRoleService.class, method = "getByName",
            groups = {RoleSave.class, RoleUpdate.class})
    private String roleName;
}
